home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / program / ewtdebug.zip / TEST.C < prev    next >
Text File  |  1990-11-23  |  3KB  |  121 lines

  1. # include "windows.h"
  2. # include "ewtdebug.h"
  3.  
  4. HANDLE hInst;
  5. HWND hRulerWnd;
  6. BYTE bSnapFlag = FALSE;
  7.  
  8. long FAR PASCAL MainWndProc (HWND, unsigned, WORD, LONG);
  9. int InitApplication (HANDLE);
  10. int InitInstance (HANDLE, int);
  11.  
  12. int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
  13. HANDLE hInstance;
  14. HANDLE hPrevInstance;
  15. LPSTR lpCmdLine;
  16. int nCmdShow;
  17. {
  18.     MSG msg;
  19.  
  20.     if (!hPrevInstance)
  21.         if (!InitApplication(hInstance))
  22.             return (FALSE);
  23.  
  24.     if (!InitInstance(hInstance, nCmdShow))
  25.         return (FALSE);
  26.  
  27.     while (GetMessage(&msg, NULL, NULL, NULL)) {
  28.         TranslateMessage(&msg);
  29.         DispatchMessage(&msg);
  30.     }
  31.     return (msg.wParam);
  32. }
  33.  
  34. BOOL InitApplication(hInstance)
  35. HANDLE hInstance;
  36. {
  37.     WNDCLASS  wc;
  38.  
  39.     wc.style = NULL;
  40.     wc.lpfnWndProc = MainWndProc;
  41.     wc.cbClsExtra = 0;
  42.     wc.cbWndExtra = 0;
  43.     wc.hInstance = hInstance;
  44.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  45.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  46.     wc.hbrBackground = GetStockObject(WHITE_BRUSH);
  47.     wc.lpszMenuName =  (LPSTR) "TTT";
  48.     wc.lpszClassName = (LPSTR) "Test_Class";
  49.  
  50.     return (RegisterClass(&wc));
  51. }
  52.  
  53. BOOL InitInstance(hInstance, nCmdShow)
  54.     HANDLE          hInstance;
  55.     int             nCmdShow;
  56. {
  57.     HWND            hWnd;
  58.  
  59.     hInst = hInstance;
  60.  
  61.     hWnd = CreateWindow(
  62.         "Test_Class",
  63.         "Ruler Test Application",
  64.         WS_OVERLAPPEDWINDOW,
  65.         0,
  66.         0,
  67.         GetSystemMetrics(SM_CXSCREEN),
  68.         GetSystemMetrics(SM_CYSCREEN),
  69.         NULL,
  70.         NULL,
  71.         hInstance,
  72.         NULL
  73.     );
  74.  
  75.     if (!hWnd)
  76.         return (FALSE);
  77.  
  78.     ShowWindow(hWnd, nCmdShow);
  79.     UpdateWindow(hWnd);
  80.     return (TRUE);
  81.  
  82. }
  83.  
  84. long FAR PASCAL MainWndProc(hWnd, message, wParam, lParam)
  85. HWND hWnd;
  86. unsigned message;
  87. WORD wParam;
  88. LONG lParam;
  89. {
  90.     int x;
  91.  
  92.     switch (message) {
  93.  
  94.     case WM_CREATE:
  95.         CreateDebugWindow (hWnd);
  96.         return (DefWindowProc(hWnd, message, wParam, lParam));
  97.  
  98.     case WM_COMMAND:
  99.         switch (wParam) {
  100.         case 100:
  101.             DBG_PutString ("test 1", "this is a string");
  102.             break;
  103.  
  104.         case 101:
  105.             for (x=0; x<50; x++)
  106.                 DBG_PutInt ("test 2", x);
  107.             break;
  108.  
  109.         case 102:
  110.             for (x=0; x<100; x++)
  111.                 DBG_PutInt ("test 3", x);
  112.             break;
  113.         }
  114.         break;
  115.  
  116.     default:
  117.         return (DefWindowProc(hWnd, message, wParam, lParam));
  118.     }
  119.     return (NULL);
  120. }
  121.